package cn.tedu.spring.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * 注入对象类型的数据
 */
@Service
public class UserService {
    @Value("业务名称")
    private String name;
    /*
      Autowired注解：自动装配
      1.注入对象[Java类型]或者接口[interface]类型的数据；
      2.添加位置：
       2.1：属性上；
       2.2：ser方法上；
       2.3：构造方法上；
     */
    @Autowired
    private UserDao userDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public UserService(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public String toString() {
        return "UserService{" +
                "name='" + name + '\'' +
                ", userDao=" + userDao +
                '}';
    }
}
